<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let student = {
          name: "翠花",
          age: 18,
          gender: "女",
          hobby: ["跳舞", "唱歌", "rap"],
          friends: [
            { name: "小明", age: 20 },
            { name: "小红", age: 19 },
            { name: "小亮", age: 21 },
            { name: "小丽", age: 22 },
            { name: "小李", age: 23 },
            { name: "小王", age: 24 }
          ]
        };
    
        // 解构出学生的姓名、年龄和性别
        let { name: studentName, age: studentAge, gender: studentGender } = student;
        console.log(`我的姓名是:${studentName}`);
        console.log(`我的年龄是:${studentAge}`);
        console.log(`我的性别是:${studentGender}`);
    
        // 解构出学生的第一个爱好
        let [firstHobby,...otherHobbies] = student.hobby;
        console.log(`我最爱的爱好是:${firstHobby}`);
        console.log(`我的其他爱好是: ${JSON.stringify(otherHobbies)}`);
    
        // 解构出学生的第一个朋友的信息
        let [friendWithInfo] = student.friends;
        console.log(`我最好朋友的信息:fname:'${friendWithInfo.name}',age:${friendWithInfo.age}`);
    
        // 找到年龄为 22 岁的朋友并输出其名字
        let friendWithAge22 = student.friends.find(friend => friend.age === 22);
        if (friendWithAge22) {
          console.log(`我有一个 22 岁的朋友, 名字叫${friendWithAge22.name}`);
        }
      </script>
</body>
</html>